<?php
namespace tp5_lib\api\exception;

use think\exception\Handle;
use Exception;

class ApiExceptionHandle extends Handle
{
    public function render(Exception $e)
    {
        $result=[
            "code"=>0,
            "msg"=>"未捕获的异常",
            "data"=>[
                "type"=>"exception",
                "message"=>$e->getMessage(),
                "code"=>$e->getCode(),
                "file"=>$e->getFile(),
                "line"=>$e->getLine(),
                "trace"=>$e->getTrace(),
            ],
        ];
        return json($result);
    }
}
